package com.example.oauth2.base.common.domain;

import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;

@MappedSuperclass
@Data
public class BaseEntity extends BaseEntityNoUpdate {
    private static final long serialVersionUID = 6779129876862398605L;

    /**
     * 更新人ID
     */
    @Column(name = "updater_id",
            length = 32,
            columnDefinition = "varchar(32) COMMENT '更新人ID'")
    @ApiModelProperty(hidden = true) // 在swagger-ui的Parameters中，隐藏此字段
    @JSONField(serialize = false)
    protected String updaterId;

    /**
     * 更新时间
     */
    @Column(name = "update_time",
            columnDefinition = "datetime COMMENT '更新时间'")
    @Temporal(TemporalType.TIMESTAMP)
    @org.hibernate.annotations.UpdateTimestamp
    @ApiModelProperty(hidden = true) // 在swagger-ui的Parameters中，隐藏此字段
    protected Date updateTime;

    /**
     * 版本
     */
    @Version
    @Column(name = "version", columnDefinition = "int DEFAULT 0 COMMENT '版本'")
    @ApiModelProperty(hidden = true) // 在swagger-ui的Parameters中，隐藏此字段
    protected Integer version;

}
